<?php
/**
 * Copyright 2011  SURFfoundation
 * 
 * This file is part of ESCAPE.
 * 
 * ESCAPE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ESCAPE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ESCAPE.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * For more information:
 * http://escapesurf.wordpress.com/
 * http://www.surffoundation.nl/
 * 
 * Contact: d.vierkant@utwente.nl
 * 
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3
 */
?>
<?php
// post config load checks

/* ===== Configuration post processing ===== */

// copy the global proxy server URL to the metaextractor config
if(!$escape_config['metaextractor']['proxy_server_url'])
{
	$escape_config['metaextractor']['proxy_server_url'] = $escape_config['proxy_server_url'];
}

// use the server URL as the default OAI repository identifier
if(!$escape_config['oai_repository_identifier'])
{
	$escape_config['oai_repository_identifier'] = preg_replace('~^.+://~i', '', $escape_config['server_url']);
}

/* ===== Check if the configuration is complete ===== */

if(!isset($escape_config['data_object_namespace']))
{
	print 'Error: the setting "data_object_namespace" needs to be set in the configuration.';
	die;
}
if(!isset($escape_config['user_object_namespace']))
{
	print 'Error: the setting "user_object_namespace" needs to be set in the configuration.';
	die;
}
if(!isset($escape_config['system_object_namespace']))
{
	print 'Error: the setting "system_object_namespace" needs to be set in the configuration.';
	die;
}

//TODO: add more checks to see if the configuration is complete

/* ===== Check for outdated configuration settings ===== */

if(isset($escape_config['triple_store_implementation_class']))
{
	print 'Error: the triple store configuration format changed, see release_notes.txt for more information.';
	die;
}

if(isset($escape_config['fedora_url']))
{
	print 'Error: the Fedora configuration format changed, see release_notes.txt for more information.';
	die;
}

